class AddNewIndices < ActiveRecord::Migration
  def self.up
    add_index(:authors, [:name])
    add_index(:reports, [:source_id])
    add_index(:reports, [:author_id])
    add_index(:reports, [:created_at])
    execute("create unique index index_reports_on_author_id_and_title_and_content on reports (author_id, title, content(128))")
    add_index(:search_runs, [:timespan_id, :search_id], :unique => true)
    add_index(:taggings, [:report_id, :tag_id], :unique => true)
    add_index(:url_refs, [:report_id, :url_id], :unique => true)
  end

  def self.down
    remove_index(:authors, [:name])
    remove_index(:reports, [:source_id])
    remove_index(:reports, [:author_id])
    remove_index(:reports, [:created_at])
    execute("drop index index_reports_on_author_id_and_title_and_content on reports")
    remove_index(:search_runs, [:timespan_id, :search_id], :unique => true)
    remove_index(:taggings, [:report_id, :tag_id], :unique => true)
    remove_index(:url_refs, [:report_id, :url_id], :unique => true)
  end
end
